home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 March / EnigmA AMIGA RUN 05 (1996)(G.R. Edizioni)(IT)[!][issue 1996-03][Skylink CD IV].iso / earcd / program / amcfp140.lha / AMCAF_Examples / QsinCosArcSqr.AMOS / QsinCosArcSqr.amosSourceCode
AMOS Source Code  |  1996-01-19  |  2KB  |  45 lines

  1. ' ************************************* Commands used: 
  2. ' *                                   * =Qarc
  3. ' *           Amcaf Examples          * =Qsqr  
  4. ' *     Qsin-Qcos-Qarc-Qsqr V1.0      * =Qsin  
  5. ' *      Written by Chris Hodges      * =Qcos  
  6. ' *                                   * Blitter Clear  
  7. ' *************************************  
  8. '
  9. ' Open a nice little screen. Ntsc is supported for Gregs sanity ;-)
  10. Screen Open 0,320,256+Ntsc*56,2,0
  11. Curs Off : Flash Off : Paper 0 : Pen 1 : Cls 
  12. ' Limit the mouse to it's boundaries.
  13. Wait Vbl 
  14. Limit Mouse 
  15. ' Now turn on double buffering... not really required, but makes the 
  16. ' program much nicer 
  17. Double Buffer : Autoback 0
  18. ' Calculate the point in the middle of the screen  
  19. MX=Screen Width/2 : MY=Screen Height/2
  20. ' Main loop
  21. Repeat 
  22.   ' Swap screens and clear old page. 
  23.   Screen Swap : Wait Vbl 
  24.    Extension_8_121C 0,0
  25.   ' Get the mouse coordinates. 
  26.   XM=X Screen(X Mouse) : YM=Y Screen(Y Mouse)
  27.   ' Calculate the delta coordinates to the middle
  28.   DX=XM-MX : DY=YM-MY
  29.   ' The angle is calculated using the Qarc function
  30.   ARC= Extension_8_16C2(DX,DY)
  31.   ' Get the distance to the middle 
  32.   RAD= Extension_8_1366(DX*DX+DY*DY)
  33.   ' Draw a line from the middle to a point in 32 pixels distance 
  34.   Draw MX,MY To MX+ Extension_8_1114(ARC,32),MY+ Extension_8_1106(ARC,32)
  35.   ' If the radius is not zero, draw a circle around the middle 
  36.   If RAD Then Circle MX,MY,RAD
  37.   ' Now unveil the information aquired.
  38.   Home 
  39.   Print "Delta X:";DX;" pixels"
  40.   Print "Delta Y:";DY;" pixels"
  41.   Print "Radius :";RAD;" pixels"
  42.   Print "Angle  :";ARC;"=";(ARC*360)/1024;" degrees"
  43. Until Inkey$=Chr$(27) or Mouse Key
  44. Screen Close 0
  45. End